﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using VIT.Web.UI;
using VIT.Library.Web;
using VIT.DataHelper.DataAccess;

namespace VIT.Wedding.Components.Home
{
    public partial class Service : VITComponent
    {
        private void LoadSkinBanner(string Position)
        {
            var pars = new Dictionary<string, string>();
            pars["Position"] = Position;
            pars["Width"] = "732";
            pars["Height"] = "301";
            LoadModule(SkinBanner, "SlideshowNumber", pars);
        }
        private void LoadSkinBannerProduct(string catId)
        {
            if (!string.IsNullOrEmpty(catId))
            {
                var pars = new Dictionary<string, string>();
                pars["Id"] = catId;
                LoadModule(SkinBannerProduct, "CategoryDetail", pars);
            }
        }
        private void LoadSkinCenter(string catID, string catName)
        {
            if (!string.IsNullOrEmpty(catID))
            {
                var pars = new Dictionary<string, string>();
                pars["Category"] = catID;
                pars["InChildCat"] = "true";
                LoadModule(SkinCenter, "Products", pars, catName);
            }
        }

        private void loadProduct(int catId = 2)
        {
            VITData.OpenTransaction();
            var prosucts = VITData.GetQuery<global::VIT.DataHelper.DataAccess.Product>(o => o.CategoryId == catId && o.Deleted == false && o.Published == true)
                .Join(VITData.GetQuery<Products_Language>(c => c.LanguageId == Session["language"].ToString()), c => c.Id, c => c.ProductId, (c, d) => new { d.ProductId, c.Image, d.Title }).ToArray();
            VITData.RollbackTransaction();

            rptProduct.DataSource = prosucts;
            rptProduct.DataBind();
        }

        protected new void Page_PreInit(object sender, EventArgs e)
        {
            base.Page_PreInit(sender, e);
                LoadSkinBannerProduct("56");
                LoadSkinBanner("BannerServices");
                loadProduct(56);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }
}